﻿using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using Cosmos.System.Filesystem.FAT;
using Cosmos.Hardware.BlockDevice;
using Gynx.Parser;
namespace Gynx
{
    public class Kernel : Sys.Kernel
    {
        private CommandLineParser parser;

        protected override void BeforeRun()
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Gynx Booted succesfully");

            //Output the hint text
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("-----------------------------------------------------------");
            Console.WriteLine("Type HELP to get a list of all the commands");

            parser = new CommandLineParser();

        }

        protected override void Run()
        {
            //The real deal : )
            Console.ForegroundColor = ConsoleColor.White;
            Console.Write("Gynx /> ");
            var input = Console.ReadLine();

            // Filter the first command
            String[] commandArray = input.Split(' ');
            var command = commandArray[0];

            // Create an array of arguments
            String[] argumentArray = null;
            if (commandArray.Length >= 1)
            {
                for (int i = 1; i < commandArray.GetLength(0); i++)
                {
                    argumentArray[i - 1] = commandArray[i];
                }
            }
            parser.parseCommand(command, argumentArray);
            //Console.WriteLine(input);

           
        }
    }
}